//
//  NSArray+EPMModelArray.m
//  UICode001基本数据结构
//
//  Created by 马继鵬 on 17/2/12.
//  Copyright © 2017年 EPM. All rights reserved.
//

#import "NSArray+EPMModelArray.h"

@implementation NSArray (EPMModelArray)
+ (instancetype)EPM_arrayWithModel:(NSString *)modelName plist:(NSString *)plistName
{
    Class clz = NSClassFromString(modelName);
    NSAssert(clz != nil, @"模型类错误");
    NSURL* url = [[NSBundle mainBundle]URLForResource:plistName withExtension:nil];
    NSAssert(url != nil, @"plist文件名错误");
    NSArray* array = [NSArray arrayWithContentsOfURL:url];
    NSMutableArray* mutable = [NSMutableArray array];
    for (NSDictionary* dict in array)
    {
        NSObject* model = [clz new];
        [model setValuesForKeysWithDictionary:dict];
        [mutable addObject:model];
    }
    return  mutable.copy;
    
}
@end
